<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/jquery.min.js"></script>
		<script type="text/jscript">
		 $(function(){
			   $("#btn").click(function(){//给提交按钮添加单击事件
				    //获取账号和密码
				   var name = $("#name").val();
				   var pwd = $("#pwd").val();
				    alert(name+"     "+pwd);
				   $.ajax({
					  url:"CustomerServlet",
					  method:"post",
					  data:{"method":"login","c_name":name,"c_pass":pwd},
					  // data:{"name":name,"pass":pwd},
					  dataType:"json",
					  
					  success:function(result){
						    $("#msg").html(result.msg);
						    if(result.code==200){
								   window.location.href="index.html";
								   //登录成功，获取token，显示在span
								   //$("#msg").html(result.token);
							   }else if(result.code==500){
								  //登录失败，msg显示在span
								  $("#msg").html(result.msg);
							   }
						   //console.log(result.code);
						   // if(result.code==200){
							  //  //登录成功，获取token，显示在span
							  //  $("#msg").html(result.token);
						   // }else if(result.code==500){
							  // //登录失败，msg显示在span
							  // $("#msg").html(result.msg);
						   // }
					   }
				   });
			   })
		   })
				</script>
	</head>
	<body>
		<span id="msg"></span>
			账号：<input type="text" id="name" value="" /><br>
			密码：<input type="password" id="pwd" value="" />
			<button id="btn">提交 </button>
	</body>
</html>
